package ss.pku.jsa.type.inference;

import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;

public class ClassQType extends ObjectQType {
//	private static final int kind = 2;
	private Qualifier refqual = null;

	public ClassQType(ITypeBinding t, Location l, String name, boolean original) {
		super(t, l, name, original);
		this.refqual = Qualifier.makeQualifierVariable(name + "-ref", l,
				original, false, false);
		if (!t.isPrimitive())
			JqualPlugin.analysis.typesUsed.add(TypeKey.getTypeKey(t));
	}

	public ClassQType(TypeKey typekey, Location l, String name, boolean original) {
		super(typekey, l, name, original);
		this.refqual = Qualifier.makeQualifierVariable(name + "-ref", l,
				original, false, false);
		JqualPlugin.analysis.typesUsed.add(typekey);
	}

	public int getKind() {
		return 2;
	}

	public String toString() {
		return "Class " + getName();
	}

	public Qualifier getRefQual() {
		return this.refqual;
	}

	public RefQType lookupFieldQType(IVariableBinding f) {
		Profile.logMemStart("lookupFieldQType/new FieldKey");
		FieldKey fk = FieldKey.getFieldKey(f);
		Profile.logMemEnd();
		return (RefQType) getFieldQTypes().get(fk);
	}

	public RefQType lookupFieldQType(FieldKey key) {
		return (RefQType) getFieldQTypes().get(key);
	}
}
